package com.study.dao;

import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.SQLException;

public class accountDao {
    //3、获取 QueryRunner 对象，执行sql语句
    QueryRunner qr = new QueryRunner();
    public void out(Connection connection, String outUser, Double money) throws SQLException {
        String sql = "update tb_account set money=money-? where name=?";
        Object[] params = {money,outUser};
        qr.update(connection,sql,params);
    }
    public void in(Connection connection, String inUser, Double money) throws SQLException {
        String sql2 = "update tb_account set money=money+? where name=?";
        Object[] params2 = {money,inUser};
        qr.update(connection,sql2,params2);
    }
}
